import { getResourceNum } from '@/components/storybook/utilties/tools'
import { get } from 'lodash'

export default (products, integrations, rules) => {
  return products.map(record => {
    const rule = rules.find(i => i.appId === record.appId && i.type === 13)
    const code = get(rule, 'threshold.value')
    const resoures = integrations.find(i => i.dimension1 === code)
    if (resoures) {
      record.integrationLimit = resoures
      record.resourceNum = getResourceNum(resoures)
      record.integrationCode = code
      record.integrationList = [
        {
          configCode: resoures.dimension1,
          configName: resoures.dimension1,
          icon: resoures.icon
        }
      ]
    }
    return record
  }).filter(record => record.type !== 2 || record.resourceNum)
}
